<template lang="html">
  <div class="floatingWindow">
    <el-badge :value="carnum" class="item">
      <div class="list" @click="$router.push({path : '/index/shoppingTrolley'})">
        <img src="../../assets/img/shopping.png" class="shopping" alt="">
      </div>
    </el-badge>

    <div class="list">
      <img src="../../assets/img/QQ.png" class="qq" alt="">
    </div>
    <div class="list">
      <img src="../../assets/img/phone.png" class="phone" alt="">
    </div>
    <div class="list" @click="backtop">
      <img src="../../assets/img/zhiding.png" class="zhiding" alt="">
    </div>
  </div>
</template>

<script>
    import {mapState} from "vuex"
    import { mapMutations } from 'vuex'
    export default {
        name: "floatingWindow",
        data: function () {

            return {
                scrollTop: null,
            }
        },
        created() {
          this.getList();
        },
        mounted() {

        },
        computed:{
            ...mapState(["carnum"]),
        },
        methods: {
            getList () {
                this.$HttpGet("/index.php?s=/admin/home.cart/lists").then(res => {
                    if(res.code!=0){
                        return false
                    }
                    this.$store.commit('CARNUM',res.data.goods_list.length)
                })
            },
            backtop() {
                let scrollToptimer = setInterval(function () {
                    let top = document.documentElement.scrollTop;
                    let speed = top / 4;
                    if (document.documentElement.scrollTop != 0) {
                        document.documentElement.scrollTop -= speed;
                    } else {
                        document.documentElement.scrollTop -= speed;
                    }
                    if (top == 0) {
                        clearInterval(scrollToptimer);
                    }
                }, 30);
            }
        }
    }
</script>

<style lang="scss" scoped>
  .floatingWindow {
    position: fixed;
    right: 17px;
    bottom: 167px;
    z-index: 99;
      /deep/.el-badge__content.is-fixed{
        top:15px;
        right: 20px;
    }
    .list {
      width: 50px;
      height: 50px;
      line-height: 50px;
      border-radius: 50%;
      border: 1px solid #D2D2D2;
      background-color: rgba(0, 0, 0, 0.2);
      text-align: center;
      margin-top: 8px;
      cursor: pointer;

      .shopping {
        width: 23px;
        height: 20px;
      }

      .qq {
        width: 19px;
        height: 20px;
      }

      .phone {
        width: 22px;
        height: 20px;
      }

      .zhiding {
        width: 20px;
        height: 20px;
      }

      &:hover {
        background: #3a62ca;
      }
    }
  }
</style>
